    <?php

class Application_Form_frmProjeto extends ZendX_JQuery_Form
{

    public function init()
    {
        $decorator_hidden_element = array(
            'ViewHelper',
            array(
                array('data'=>'HtmlTag'), 
                array('tag' => 'td')),
            array(
                array('row'=>'HtmlTag'),
                array('tag'=>'tr','style'=>'display:none'))
           );
        
        $decorator_element = array(
            'ViewHelper',
            'Description',
            'Errors',
            array(
                array('data'=>'HtmlTag'), 
                array('tag' => 'td')),
            array('Label',  
                array('tag' => 'td', 'style'=>'float:right;')),
            array(
                array('row'=>'HtmlTag'),
                array('tag'=>'tr'))
           );
        
        $decorator_submit = array(
           'ViewHelper',
           'Description',
           'Errors', array(
               array('data'=>'HtmlTag'), 
               array('tag' => 'td', 'colspan'=>'2','align'=>'center')),
           array(
               array('row'=>'HtmlTag'),
               array('tag'=>'tr'))
        );

        $decorator_form = array(
            'FormElements',
            array(
                array('data'=>'HtmlTag'),
                array('tag'=>'table')),
            'Form'
        );
  
        $this->setAttrib('accept-charset', 'utf-8')
            ->setName('tarefa');
        
        // campo id
        $id = new Zend_Form_Element_Hidden('id');
        $id->addFilter('Int');
        $id->setDecorators($decorator_hidden_element);
        $this->addElement($id);

        // campo tipo_id
        $tipos = new DbTable_TarefasTipo();
        $tipo_id = new Zend_Form_Element_Select('tipo_id');
        $tipo_id->setLabel('Tipo');
        $result = $tipos->fetchAll();
        foreach($result as $tipo):
            $tipo_id->addMultiOption($tipo->id,$tipo->tipo);
        endforeach;
        $tipo_id->setDecorators($decorator_element);
        $this->addElement($tipo_id);
        
        //campo projeto
        $projeto = new Zend_Form_Element_Text('projeto');
        $projeto->setLabel('Projeto')
            ->setAttrib('size', 50)
            ->setRequired(true)
            ->addFilter('StripTags')
            ->addFilter('StringTrim')
            ->addValidator('NotEmpty')
            ->setDecorators($decorator_element);
        $this->addElement($projeto);

        // campo responsavel_id
        $usuarios = new DbTable_Usuarios();
        $responsavel_id = new Zend_Form_Element_Select('responsavel_id');
        $responsavel_id->setLabel('Responsável');
        $result = $usuarios->fetchAll(null,'nome');
        foreach($result as $usuario):
            $responsavel_id->addMultiOption($usuario->id,$usuario->nome);
        endforeach;
        $responsavel_id->setDecorators($decorator_element);
        $this->addElement($responsavel_id);
        
        $decorator_data_element = array(
            'UiWidgetElement',
            'Description',
            'Errors',
            array(array('data'=>'HtmlTag'), array('tag' => 'td')),
            array('Label',  array('tag' => 'td', 'style'=>'float:right;')),
            array(array('row'=>'HtmlTag'),array('tag'=>'tr'))
           );
        
        
        $data_inicio = new ZendX_JQuery_Form_Element_DatePicker(
            'dt_inicio',array('jQueryParams' => array(
            'dateFormat' => 'dd/mm/yy',
            'defaultDate' => date('',time()) )));
        $data_inicio->setLabel('Data Início')
            ->setRequired ()
            ->setDecorators($decorator_data_element);
        $this->addElement($data_inicio);

        $data_estimada = new ZendX_JQuery_Form_Element_DatePicker(
            'dt_estimada',array('jQueryParams' => array(
            'dateFormat' => 'dd/mm/yy',
            'defaultDate' => date('',time()) )));
        $data_estimada->setLabel('Data Estimada')
            ->setRequired ()
            ->setDecorators($decorator_data_element);
        $this->addElement($data_estimada);

        // botão submit
        $submit = new Zend_Form_Element_Submit('submit_projeto');
        $submit->setAttrib('id', 'submitbutton')
            ->setDecorators($decorator_submit);
        $this->addElement($submit);
        
        $this->setDecorators($decorator_form);
    }


}

